package com.logistics.route.entity.model;

import com.logistics.route.entity.domain.Route;
import com.logistics.utils.aspect.annotation.Dictionary;
import com.logistics.utils.tool.DateUtils;
import lombok.Data;

import java.util.List;

@Data
public class RouteRow {

    private Integer id;

    private String name;

    private String path;

    @Dictionary(key = "route_method")
    private String method;

    private String component;

    private Integer parentId;

    private String creator;

    private String createTime;

    private String updater;

    private String updateTime;

    private List<RouteRow> children;

    public RouteRow(){

    }

    public RouteRow(Route route){
        this.id = route.getId();
        this.name = route.getName();
        this.parentId = route.getParentId();
        this.path = route.getPath();
        this.method = route.getMethod();
        this.component = route.getComponent();
        this.creator = route.getCreator();
        this.createTime = DateUtils.dateToStringFormat(route.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
        this.updater = route.getUpdater();
        this.updateTime = DateUtils.dateToStringFormat(route.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
    }

    public static RouteRow build(Route route){
        return new RouteRow(route);
    }

}
